home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / utils hack / Stay Off If Up Hack 1.0 / upoffhack.exe / upoffhack.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-27  |  1.8 KB  |  60 lines

  1.     /*
  2.     Stay Off If Up Hack - PalmOS Hack to stop the Palm V turning on if the
  3.     up button is held down.
  4.  
  5.     Copyright (C) 2000 Duncan Sargeant
  6.  
  7.     This library is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU Lesser General Public
  9.     License as published by the Free Software Foundation; either
  10.     version 2 of the License, or (at your option) any later version.
  11.  
  12.     This library is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     Lesser General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU Lesser General Public
  18.     License along with this library; if not, write to the Free Software
  19.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20.  
  21.     */
  22.  
  23.  
  24.  
  25. #include <Pilot.h>
  26. #include <System/Globals.h>
  27. #include <System/AlarmPrv.h>
  28. #include <Hardware/Hardware.h>
  29. #include <System/KeyMgr.h>
  30.  
  31. #define mycreator 'upoh'
  32.  
  33. #define myresourceid 1000
  34.  
  35. void MySysTrapSleep (Boolean untilReset, Boolean emergency) {
  36.     DWord keystate, temp;
  37.     void (*oldtrap)(Boolean, Boolean);
  38.  
  39.     /* first do everything a normal sleep would do by calling the real one */
  40.     FtrGet (mycreator, myresourceid, &temp);
  41.     oldtrap = (void (*)(Boolean, Boolean)) temp;
  42.     oldtrap(untilReset, emergency);
  43.  
  44.     /* we don't really want to fuck with things in these situations */
  45.     if (untilReset || emergency) {
  46.         return;
  47.     }
  48.  
  49.     /* this loop ensures that if the up scroll key is pressed
  50.        down, then the pilot goes back to sleep.  The exception is
  51.        when an alarm is triggered (for obvious reasons). */
  52.  
  53.     keystate = KeyCurrentState();
  54.     while (keystate & keyBitPageUp
  55.             && !((AlmGlobalsPtr) GAlmGlobalsP)->triggered) {
  56.         HwrSleep (0, 0);
  57.         keystate = KeyCurrentState();
  58.     }
  59. }
  60.